home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 676 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.3 KB

  1. From: lars.farm@nts.mh.se (Lars Farm)
  2. Message-ID: <AD672E17966850AA2@sleipner.nts.mh.se>
  3. X-Original-Date: Sat, 09 Mar 1996 12:46:15 +0100
  4. Path: in1.uu.net!bounce-back
  5. Date: 09 Mar 96 15:42:58 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: 'const' in header files
  9. Organization: pv
  10. References: <AD64B66E966816216@sleipner.nts.mh.se> <4hn54s$3am@engnews1.Eng.Sun.COM>
  11. Content-Type: text/plain; charset=iso-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMUGnDuEDnX0m9pzZAQEI8wF9Gd2rmByQCiXmPc+JLJ92GwzKzUfTWgKZ
  15.     zqdmBY7qqxcKzuCtQV3VNKzZt/wr7wO3
  16.     =kP8+
  17.  
  18. In article <4hn54s$3am@engnews1.Eng.Sun.COM>,
  19. clamage@Eng.Sun.COM (Steve Clamage) wrote:
  20.  
  21. >Next, why single out this one particular optimization?
  22.  
  23. To kill the #preprocessor.
  24.  
  25. I do not consider it an optimization. It is not about performance. It is
  26. about semantics. I have viewed X from "const built_in_type X =
  27. some_compiler_generated_value;" as a constant. More or less as some kind of
  28. #define that knows about scope. Perhaps this view is incorrect. It is not a
  29. constant. It is a local variable, but a variable you're not allowed to
  30. alter? 
  31.  
  32. To me there is a difference in interpretation between constant and
  33. variable. I would like to see that semantic difference reflected in the
  34. standard. I believe that it already is to some extent, but only for integer
  35. types.
  36.  
  37. const int N = 10;
  38. int arr[N]; // this is not about optimization, is it?
  39.  
  40. In article <4hqd3e$n7k@news.aosi.com>,
  41. yeager@aosi.com wrote:
  42.  
  43. >One area where such a requirement conflicts with existing rules would
  44. >be if the constant object has a constructor.  Then the existing rules
  45. >would not allow the constant to be omitted since the constructor must
  46. >be called (especially if it has detectable side effects) even if the
  47. >constant is not used in the particular compilation unit.
  48.  
  49. I talk about built in types: short, int, float, double, char, etc. Their
  50. constructors do not have any side effects.
  51.  
  52. --
  53. Lars Farm, lars.farm@nts.mh.se
  54. ---
  55. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  56. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  57. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  58. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  59. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  60.